class CompteVersion1 extends Compte {

    String curNumber;

    protected double solde;

    CompteVersion1(double i) {
        solde = i;
    }

    public synchronized void deposer(double montant) {
        curNumber = (Thread.currentThread()).getName();
        System.out.println(curNumber + " DEBUT deposer " + solde);
        solde = solde + montant;
        notify();
        System.out.println(curNumber + " |---- deposer ");
    }

    public synchronized void retirer(double montant) {
        curNumber = (Thread.currentThread()).getName();
        System.out.println(curNumber + " DEBUT retirer " + solde);
        try {
            while (solde < montant)
                wait();
            curNumber = (Thread.currentThread()).getName();
        } catch (Exception e) {
        }
        solde = solde - montant;
        System.out.println(curNumber + " |---- retirer ");
    }

    public synchronized double consulter() {
        return solde;
    }
}
